package com.one.friend.controller.question;

import com.one.common.core.controller.BaseController;
import com.one.common.core.domain.R;
import com.one.common.core.domain.TableDataInfo;
import com.one.friend.domain.question.dto.QuestionQueryDTO;
import com.one.friend.domain.question.vo.QuestionDetailVO;
import com.one.friend.domain.question.vo.QuestionVO;
import com.one.friend.service.question.IQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/question")
public class QuestionController extends BaseController {

    @Autowired
    private IQuestionService questionService;


    /**
     *      接口概述  根据过滤条件返回对应的题目列表信息
     *      接口地址  /question/semiLogin/list
     *      请求方法  get
     *      请求参数  QuestionQueryDTO
     *      响应数据  TableDataInfo
     */
    @GetMapping("/semiLogin/list")
    public TableDataInfo list(QuestionQueryDTO questionDTO){
        return questionService.list(questionDTO);
    }

    @GetMapping("/detail")
    public R<QuestionDetailVO> detail(Long questionId){
        return R.ok(questionService.detail(questionId));
    }
    @GetMapping("/preQuestion")
    public R<String> preQuestion(Long questionId){
        return R.ok(questionService.preQuestion(questionId));
    }
    @GetMapping("/nextQuestion")
    public R<String> nextQuestion(Long questionId){
        return R.ok(questionService.nextQuestion(questionId));
    }

    // 获取题目热榜排行
    @GetMapping("/semiLogin/hotQuestion")
    public R<List<QuestionVO>> getHotQuestionList() {
        return R.ok(questionService.getHotQuestionList());
    }

}
